package com.ewanghuiju.app.widget.popupwindow;

import android.content.Context;
import android.view.View;

import com.ewanghuiju.app.R;
import com.ewanghuiju.app.util.nodoubleclick.AntiShake;

import butterknife.ButterKnife;
import butterknife.OnClick;
import razerdp.basepopup.BasePopupWindow;

/**
 * @author sj  qq:751943509
 * @class 邀请好友弹框
 * @time 2020/2/19
 */
public class InviteFriendPopup extends BasePopupWindow {

    private ShareItemClickCallback shareItemClickCallback;

    public InviteFriendPopup(Context context, ShareItemClickCallback shareItemClickCallback) {
        super(context);
//        AutoSize.cancelAdapt((Activity) context);
        setWidth(getScreenWidth());
        this.shareItemClickCallback = shareItemClickCallback;
        ButterKnife.bind(this, getContentView());
    }

    @Override
    public View onCreateContentView() {
        return createPopupById(R.layout.popup_invite_friend);
    }

    @OnClick({R.id.popup_close, R.id.tv_baocun, R.id.tv_wx, R.id.tv_friend, R.id.tv_qq, R.id.tv_wb})
    public void doClick(View view) {
        if (AntiShake.check(view.getId())) {    //判断是否多次点击
            return;
        }

        switch (view.getId()) {
            case R.id.popup_close:
                dismiss();
                break;
            case R.id.tv_baocun:
                dismiss();
                if (shareItemClickCallback != null)
                    shareItemClickCallback.saveImage();
                break;
            case R.id.tv_wx:
                dismiss();
                if (shareItemClickCallback != null)
                    shareItemClickCallback.wxShare();
                break;
            case R.id.tv_friend:
                dismiss();
                if (shareItemClickCallback != null)
                    shareItemClickCallback.friendShare();
                break;
            case R.id.tv_qq:
                dismiss();
                if (shareItemClickCallback != null)
                    shareItemClickCallback.qqShare();
                break;
            case R.id.tv_wb:
                dismiss();
                if (shareItemClickCallback != null)
                    shareItemClickCallback.wbShare();
                break;
            default:
                break;
        }
    }

    public interface ShareItemClickCallback {
        void saveImage();

        void wxShare();

        void friendShare();

        void qqShare();

        void wbShare();
    }

}
